<%--
  Created by IntelliJ IDEA.
  User: chen
  Date: 2023/3/8
  Time: 13:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>申请记录</title>
    <link href="css/themes/default/easyui.css" rel="stylesheet"/>
    <link href="css/themes/icon.css" rel="stylesheet"/>
    <link href="css/themes/color.css" rel="stylesheet"/>
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="script/jquery.min.js"></script>
    <script src="script/jquery.easyui.min.js"></script>
    <script src="script/easyui-lang-zh_CN.js"></script>

    <style>
        body {
            font-size: 12px;
            overflow-y: hidden;
        }

        input {
            width: 100px;
        }

        select {
            width: 104px;
        }

        #sec {
            /*border:1px solid #0094ff;*/
            width: 1000px;

        }

        #sec td {
            width: 100px;
            height: 20px;
            text-align: right
        }
    </style>
</head>
<body>


<div>
    <table id="sec">
        <tr>
            <td>寄件人姓名:</td>
            <td><input type="text" class="easyui-textbox" id="senderName" name="senderName"/></td>
            <td>收件人姓名:</td>
            <td><input type="text" class="easyui-textbox" id="recipientName" name="recipientName"/></td>
            <td>送货人:</td>
            <td><input type="text" class="easyui-textbox" id="delivery" name="delivery"/></td>
        </tr>
        <tr>
            <td>快递单号:</td>
            <td><input type="text" class="easyui-textbox" id="waybillNo" name="waybillNo"/></td>
            <td>寄件人地址:</td>
            <td>
                <input type="text" id="senderAddress" class="easyui-textbox"></input>
                <%--                <select id="sender_address">--%>
                <%--                    <option value="请选择">请选择</option>--%>
                <%--                    <option value="泉州">泉州</option>--%>
                <%--                    <option value="厦门">厦门</option>--%>
                <%--                </select>--%>
            </td>
            <td>收件人地址:</td>
            <td>
                <input type="text" id="recipientAddress" class="easyui-textbox"></input>
                <%--                <select id="recipient_address">--%>
                <%--                    <option>请选择</option>--%>
                <%--                    <option value="泉州">泉州</option>--%>
                <%--                    <option value="厦门">厦门</option>--%>
                <%--                </select>--%>
            </td>
        </tr>
        <tr>
            <td>快递状态:</td>
            <td>
                <input type="text" id="status" class="easyui-textbox"></input>
                <%--                <select id="status">--%>
                <%--                    <option>请选择</option>--%>
                <%--                    <option value="运输中">运输中</option>--%>
                <%--                    <option value="未发送">未发送</option>--%>
                <%--                    <option value="已送达">已送达</option>--%>
                <%--                    <option value="待修改">待修改</option>--%>
                <%--                    </select>--%>
            </td>
            <td>快递类型:</td>
            <td>
                <select id="mailType" name="mailType">
                    <option value="">请选择</option>
                    <option value="日用品">日用品</option>
                    <option value="衣物">衣物</option>
                    <option value="文件">文件</option>
                    <option value="蔬果">蔬果</option>
                </select>
            </td>
            <td>
                <button id="btn" onclick="" class="easyui-linkbutton c1" style="width:70px">查询</button>
            </td>
        </tr>
    </table>
</div>
<table name="mytable" id="mytable" border="1" style="margin:0 auto">
    <tr>
        <th>运单号</th>
        <th>寄件类型</th>
        <th>寄件人姓名</th>
        <th>寄件人电话</th>
        <th>寄件人地址</th>
        <th>收件人姓名</th>
        <th>收件人电话</th>
        <th>收件人地址</th>
        <th>寄件收费</th>
        <th>运单状态</th>
        <th>所在仓库</th>
        <th>操作</th>
    </tr>
</table>
<script type="text/javascript">
    var statusList = ["已删除/已取消", "待收取", "在库中", "运输中", "司机收件", "已送达"];
    var mailTypeList = [];

    $.ajax({
        url: "queryMailName.do",
        type: "POST",
        dataType: "json",
        success: function (data) {
            mailTypeList.push("全部")
            for (var i = 0; i < data.length; i++) {
                mailTypeList.push(data[i].mailTypeName)
            }
        }
    })

    queryAllFunc();

    function queryAllFunc() {

        $.ajax({
            url: "queryAllByAjax.do",
            type: "GET",
            data: {
                // warehouse_id:$("#warehouse_id").val(),
                waybillNo: $("#waybillNo").val(),
                mailType: $("#mailType").val(),
                senderName: $("#senderName").val(),
                // sender_phone:$("#sender_phone").val(),
                senderAddress: $("#senderAddress").val(),
                recipientName: $("#recipientName").val(),
                // recipient_phone:$("#recipient_phone").val(),
                recipientAddress: $("#recipientAddress").val(),
                mailCost: $("#mailCost").val(),
                status: $("#status").val()

            },
            dataType: "json",
            success: function (data) {

                var str = "";
                str += "<tr>";
                str += "<th>运单号</th>";
                str += "<th>寄件类型</th>";
                str += "<th>寄件人姓名</th>";
                str += "<th>寄件人电话</th>";
                str += "<th>寄件人地址</th>";
                str += "<th>收件人姓名</th>";
                str += "<th>收件人电话</th>";
                str += "<th>收件人地址</th>";
                str += "<th>寄件收费</th>";
                str += "<th>运单状态</th>";
                str += "<th>操作</th>";
                str += "</tr>";
                for (var i = 0; i < data.length; i++) {
                    str += "<tr>";
                    str += "<td>" + data[i].waybillNo + "</td>";
                    str += "<td>" + mailTypeList[data[i].mailType] + "</td>";
                    str += "<td>" + data[i].senderName + "</td>";
                    str += "<td>" + data[i].senderPhone + "</td>";
                    str += "<td>" + data[i].senderAddress + "</td>";
                    str += "<td>" + data[i].recipientName + "</td>";
                    str += "<td>" + data[i].recipientPhone + "</td>";
                    str += "<td>" + data[i].recipientAddress + "</td>";
                    str += "<td>" + data[i].mailCost + "</td>";
                    str += "<td>" + statusList[data[i].status] + "</td>";
                    if (data[i].status == 2) {
                        str += "{<td><button onclick='deleteBywaybill_no(" + data[i].waybillNo + ")'>删除</button>" +
                            "<button onclick='updateByStatus(" + data[i].waybillNo + ")'>出库</button>" +
                            "<button onclick='updateByWaybill_no(" + data[i].waybillNo + ")'>修改</button></td>";
                    } else {
                        str += "{<td><button onclick='deleteBywaybill_no(" + data[i].waybillNo + ")'>删除</button>" +
                            "<button onclick='updateByWaybill_no(" + data[i].waybillNo + ")'>修改</button></td>";
                    }
                    str += "</tr>";

                }
                $("#mytable").html(str);
            }


        });

    }


    $("#btn").click(function () {
        queryAllFunc();


    });

    function deleteBywaybill_no(waybill_no) {
        $.ajax({
            url: "deleteWaybill.do",
            type: "GET",
            data: {waybill_no: waybill_no},
            dataType: "text",
            success: function (text) {

                queryAllFunc();

            }
        });
    }

    function updateByWaybill_no(waybill_no) {
        window.location.href = 'queryWaybill.do?waybill_no=' + waybill_no;
    }

    function updateByStatus(waybill_no) {
        $.ajax({
            url: "updateByStatus.do",
            type: "GET",
            data: {waybill_no: waybill_no},
            dataType: "text",
            success: function (text) {

                queryAllFunc();

            }
        });
    }
</script>
</body>
</html>


